<?php

namespace App\Http\Controllers\Test;


use App\Models\SiteMsg;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
use App\Http\Controllers\Controller;


class TranslateController extends Controller
{


    // 翻译


    //  设置语言 ： 系统的
    // http://www.enshop.com/test/translate/one
    public function one()
    {
        //$locale = Session::get('locale');
        $locale = 'zh_CN';
        $locale = 'zh_cn';
        $locale = 'zh';

        App::setLocale($locale);
        // operation_successful

        echo __('messages.welcome');
        echo __('operation_successful');
        echo __('Username');
    }

    //  设置语言 自己的
    // http://www.enshop.com/test/translate/two
    public function two()
    {
        //$locale = Session::get('locale');
        $locale = 'zh_CN';
        $locale = 'zh_cn';
        $locale = 'zh';

        $opt = $this->optLogic();

        echo $opt->translate('messages.welcome');
        echo $opt->translate('operation_successful');
        echo $opt->translate('Username.Username.Username');
    }

    //  设置语言
    // http://www.enshop.com/test/translate/msg
    public function msg()
    {
        $msgDb = new SiteMsg();
        $langs = $msgDb->getAll();
        //$langs = array_column($langs, 'en_msg', 'field');
        $langs = array_column($langs, 'cn_msg', 'field');

        var_export($langs);
        //echo $this->optLogic()->jsonChinese($langs);
    }


}


